// diaoyu/pages/catchWeight/catchWeight.js
var $ = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
      id:'',
      id2:'',
      number:'',
      weight:'',
      info:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      console.log('2342',options)
      this.setData({
        id:options.id,
        id2:options.id2
      })
    },

    inputChange1(e){
      
      this.setData({
        number:e.detail.value
      })
      console.log('999',e.detail.value,this.data.number)
    },
    inputChange2(e){
      this.setData({
        weight:e.detail.value
      })
      console.log('999',e.detail.value,this.data.weight)
    },
    add(){
      const obj = {number:this.data.number,weight:this.data.weight}
      const arr = this.data.info
      arr.push(obj)
      console.log('342000',this.data.info)
      this.setData({
        number:'',
        weight:'',
        info: arr
      })
      console.log('342111',this.data.info)
    },
    issue(){
      let that = this
      wx.showModal({
        title: '提示',
        content: '确定发布成绩吗',
        success (res) {
          if (res.confirm) {
            console.log('用户点击确定',that.data.id,that.data.id2,that.data.info)
            $.post('yuxun/addweight',{fangdiao_id:that.data.id,diaochang_id:that.data.id2,info:that.data.info},function(res){
              wx.showToast({
                title: res.msg,
                icon:'success',
                duration:2000
              })
              setTimeout(function() {
                console.log("2 seconds have passed.");
                $.goto('/diaoyu/pages/diaodian/my')
              }, 2000);
              
            })
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
    }

})